package com.edu.coder.xcz.homwork5.t4;

public class overridingTest {
    public static void main(String[] args) {
        // 实例化子类对象s，调用talk()方法打印信息
        /********* begin *********/
        Student student = new Student("张三", 18, "哈佛大学");
        student.talk();
        /********* end *********/

    }
}

class Person {
    /********* begin *********/
    private String name;
    private Integer age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Person(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public void talk() {
        System.out.println("姓名：" + getName() + "，年龄：" + getAge());
    }
    /********* end *********/
}

class Student extends Person {
    private String school;

    /********* begin *********/
    public Student(String name, Integer age, String school) {
        super(name, age);
        this.school = school;
    }

    /********* end *********/


    @Override
    public void talk() {
        System.out.println("我是："+getName()+"，今年："+getAge()+"岁，我在"+school+"上学");
    }
}
